<template>
    <el-card class="box-card" width="100%">
  <div slot="header" class="clearfix">
    <span>数据集详情</span>
    <el-button style="float: right; padding: 1px 0; height: 35px; width: 55px" type="primary" @click="goBack()">返回</el-button>
  </div>
  <div class="forms">
    <el-form ref="detailData" :rules="rules" :model="detailData" label-width="100px" class="dataset-form">
      <el-form-item label="数据集id:" prop="datasetID">
        <el-input v-model="detailData.id" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="数据集名称：" prop="name">
        <el-input v-model="detailData.name" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="创建者：" prop="user_id">
        <el-input v-model="detailData.user_id" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="创建时间：" prop="create_date">
        <el-input v-model="detailData.create_date" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="是否公有：" prop="public">
        <el-input v-model="detailData.public" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="描述：" prop="description">
        <el-input v-model="detailData.description" type="textarea" :rows="5" maxlength=500 :disabled="role>=3||role===null"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="editDatasetProcess()" :disabled="role>=3">保存编辑</el-button>
      </el-form-item>
    </el-form>
    <!-- 数据集id: {{detailData.id}} -->
  </div>
  <!-- <div class="text item">
    数据集名称： {{detailData.name}}
  </div>
  <div class="text item">
    创建者： {{detailData.user_id}}
  </div>
  <div class="text item">
    创建时间： {{detailData.create_date}}
  </div>
  <div class="text item">
    是否公有： {{detailData.public}}
  </div>
  <div class="text item">
    描述： {{detailData.description}}
  </div> -->
</el-card>
</template>
<style scoped>
  .forms {
    font-size: 16px;
    text-align: left;
    margin-left: 1px;
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }

  .box-card {
    width: 100%;
  }

  .el-card__header {
    padding: 18px 20px;
    background-color: rgb(238, 241, 246);
  }

  .dataset-form {
    width: 90%;
    margin: 10px; /* 上下间距160px，左右自动居中*/
    background-color: rgb(255, 255, 255, 0.8); /* 透明背景色 */
    padding: 10px;
    border-radius: 20px; /* 圆角 */
  }
</style>
<script>
import { getDataset, editDataset } from '@/api/request/dataset'
import { getUserEmail } from '@/api/request/user'
// import store from '@/store/store'
export default {
//   props: ['title'],
  data () {
    return {
      detailData: null,
      role: 3
    //   title: '我创建的数据集'
    }
  },
  methods: {
    update () {
      // console.log(this.$store.getters.datasetRole)
      this.role = this.$route.query.role
      getDataset(this.$route.query.dataset_id).then(response => {
        this.detailData = response
        getUserEmail({user_id: this.detailData.user_id}).then(response => {
          this.detailData.user_id = response.email
        })
      })
    },
    goBack () {
      // this.$store.commit('setDatasetCurID', null)
      // this.$store.commit('setDatasetRole', null)
      this.$router.go(-1)
    },
    editDatasetProcess () {
      editDataset({dataset_id: this.detailData.id, name: this.detailData.name, description: this.detailData.description}).then(response => {

      })
    }
  },
  //   created () {
  //     console.log('created')
  //     this.update()
  //   },
  activated () {
    // if (store.datasetInfo.list_type === this.list_type) {
    //   console.log('==')
    //   return
    // }
    this.update()
  }
}
</script>
